﻿using Autofac;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using wnet.admin.Repositories;
using wnet.admin.wnet;

namespace wnet.admin.dbhelper
{



    public class AutofacModuleRegister : Autofac.Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            var basePath = @"E:\project2024\wenhuaju\admin\wnet.admin\wnet.admin\bin";

            var servicesDllFile = Path.Combine(basePath, "TCM.Service.dll");
            var repositoryDllFile = Path.Combine(basePath, "TCM.Repository.dll");


            //builder.RegisterType<TranAOP>();

            builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IBaseRepository<>)).InstancePerDependency(); //注册仓储
            builder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>))


                .InstancePerDependency(); //注册服务

            // 获取 Service.dll 程序集服务，并注册
            var assemblysServices = Assembly.LoadFrom(servicesDllFile);
            builder.RegisterAssemblyTypes(assemblysServices).InstancePerDependency();



        }
    }
}